package com.ruoyi.hospital.controller.consultationInfo;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hospital.domain.consultationInfo.ConsultationInfo;
import com.ruoyi.hospital.service.consultationInfo.IConsultationInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 问诊信息Controller
 * 
 * @author wendao
 * @date 2024-08-20
 */
@RestController
@RequestMapping("/hospital/consultationInfo")
public class ConsultationInfoController extends BaseController
{
    @Autowired
    private IConsultationInfoService consultationInfoService;



    /*
    * 查询医生下面的 患者列表
    * */
    @GetMapping("/memberList")
    public TableDataInfo consultationInfoList(ConsultationInfo consultationInfo)
    {
        //根据memberId进行分组
        consultationInfo.setGroupType("1");

        startPage();
        List<ConsultationInfo> list = consultationInfoService.selectConsultationInfoList(consultationInfo);
        return getDataTable(list);
    }


    /**
     * 查询问诊信息列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:consultationInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(ConsultationInfo consultationInfo)
    {
        startPage();
        List<ConsultationInfo> list = consultationInfoService.selectConsultationInfoList(consultationInfo);
        return getDataTable(list);
    }

    /**
     * 导出问诊信息列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:consultationInfo:export')")
    @Log(title = "问诊信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ConsultationInfo consultationInfo)
    {
        List<ConsultationInfo> list = consultationInfoService.selectConsultationInfoList(consultationInfo);
        ExcelUtil<ConsultationInfo> util = new ExcelUtil<ConsultationInfo>(ConsultationInfo.class);
        util.exportExcel(response, list, "问诊信息数据");
    }

    /**
     * 获取问诊信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:consultationInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(consultationInfoService.selectConsultationInfoById(id));
    }

    /**
     * 新增问诊信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:consultationInfo:add')")
    @Log(title = "问诊信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ConsultationInfo consultationInfo)
    {
        return toAjax(consultationInfoService.insertConsultationInfo(consultationInfo));
    }

    /**
     * 修改问诊信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:consultationInfo:edit')")
    @Log(title = "问诊信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ConsultationInfo consultationInfo)
    {
        return toAjax(consultationInfoService.updateConsultationInfo(consultationInfo));
    }

    /**
     * 删除问诊信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:consultationInfo:remove')")
    @Log(title = "问诊信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(consultationInfoService.deleteConsultationInfoByIds(ids));
    }
}
